home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet 2002 February / Practical Internet February 2002.iso / pc / Software / Browsing / httrack-3.09e2.exe / {app} / src_win / WinHTTrack / WinHTTrack.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-28  |  20.3 KB  |  819 lines

  1. // WinHTTrack.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "WinHTTrack.h"
  6.  
  7. #include "Shell.h"
  8. #include "winsock.h"
  9.  
  10. #include "wid1.h"
  11. #include "maintab.h"
  12.  
  13. #include "MainFrm.h"
  14. #include "splitter.h"
  15. #include "about.h"
  16.  
  17. #include "WinHTTrackDoc.h"
  18. #include "WinHTTrackView.h"
  19.  
  20. #include "inprogress.h"
  21.  
  22. /* HTS - HTTRACK */
  23. #include "htsglobal.h"
  24.  
  25. #ifdef _DEBUG
  26. #define new DEBUG_NEW
  27. #undef THIS_FILE
  28. static char THIS_FILE[] = __FILE__;
  29. #endif
  30.  
  31. //
  32. #include "DialogContainer.h"
  33. #include "InfoUrl.h"
  34.  
  35. // PAS de domodal a l'exterieur!!!!!
  36. #include "wizard.h"
  37. #include "wizard2.h"
  38. #include "WizLinks.h"
  39. extern char WIZ_question[1000];
  40. extern char WIZ_reponse[1000];
  41.  
  42.  
  43. extern Wid1* dialog1;
  44. extern CMainTab* maintab;
  45. extern Cinprogress* inprogress;
  46. extern CShellApp* CShellApp_app;
  47. extern int termine;
  48. extern int termine_requested;
  49. extern int soft_term_requested;
  50. extern int shell_terminated;
  51. extern CInfoUrl* _Cinprogress_inst;
  52. extern int LibRasUse;
  53.  
  54. extern "C" {
  55.   char* hts_rootdir(char* file);
  56. };
  57.  
  58.  
  59. // rmdir
  60. #include <direct.h>
  61.  
  62. // linput
  63. extern "C" {
  64.   void linput(FILE* fp,char* s,int max);
  65.   void linput_trim(FILE* fp,char* s,int max);
  66.   void linput_cpp(FILE* fp,char* s,int max);
  67. };
  68.  
  69. // HTTrack main vars
  70. HWND App_Main_HWND;
  71. CSplitterFrame* this_CSplitterFrame=NULL;
  72. HICON httrack_icon;
  73. // Helper
  74. LaunchHelp* HtsHelper=NULL;
  75.  
  76. // dirtreeview
  77. #include "DirTreeView.h"
  78. extern CDirTreeView* this_DirTreeView;
  79.  
  80. // New Project
  81. #include "NewProj.h"
  82. extern CNewProj* dialog0;
  83.  
  84.  
  85. // InfoEnd
  86. #include "infoend.h"
  87. extern Cinfoend* this_Cinfoend;
  88.  
  89. // Pointeur sur nous
  90. CWinHTTrackApp* this_app=NULL;
  91.  
  92. // fexist
  93. extern "C" int fexist(char*);
  94.  
  95. /////////////////////////////////////////////////////////////////////////////
  96. // CWinHTTrackApp
  97.  
  98. BEGIN_MESSAGE_MAP(CWinHTTrackApp, CWinApp)
  99.     //{{AFX_MSG_MAP(CWinHTTrackApp)
  100.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  101.     ON_COMMAND(ID_FILE_SAVE, OnFileSave)
  102.     ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
  103.     ON_COMMAND(ID_FILE_MRU_FILE1, OnFileMruFile1)
  104.     //}}AFX_MSG_MAP
  105.   ON_COMMAND(wm_ViewRestart,OnViewRestart)
  106.   ON_COMMAND(wm_WizRequest1,OnWizRequest1)
  107.   ON_COMMAND(wm_WizRequest2,OnWizRequest2)
  108.   ON_COMMAND(wm_WizRequest3,OnWizRequest3)
  109.     // Standard file based document commands
  110.     //ON_COMMAND(ID_FILE_WIZARD, OnWizard)
  111.     ON_COMMAND(ID_FILE_NEW, OnFileNew)
  112.     ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
  113.     ON_COMMAND(ID_FILE_DELETE_PROJ, OnFileDelete)
  114.     ON_COMMAND(ID_FILE_BROWSE_SIT, OnBrowseWebsites)
  115.   ON_COMMAND(IDC_langprefs,Onipabout)
  116.   ON_COMMAND(ID_ABOUT,Onipabout)
  117.   ON_COMMAND(ID_UPDATE,OnUpdate)
  118.     ON_COMMAND(ID_HELP_FINDER,OnHelpInfo2)
  119.     ON_COMMAND(ID_HELP,OnHelpInfo2)
  120.     //ON_COMMAND(ID_CONTEXT_HELP,OnContextHelp)
  121.     ON_COMMAND(ID_DEFAULT_HELP,OnHelpInfo2)
  122.   // Forward to inprogress
  123.   ON_BN_CLICKED(ID_LOAD_OPTIONS,FwOnLoadprofile)
  124.   ON_BN_CLICKED(ID_FILE_SAVE_OPTIONS_AS,FwOnSaveprofile)
  125.     ON_BN_CLICKED(ID_LoadDefaultOptions, FwOnLoaddefault)
  126.     ON_BN_CLICKED(ID_SaveDefaultOptions, FwOnSavedefault)
  127.     ON_BN_CLICKED(ID_ClearDefaultOptions,FwOnResetdefault)
  128.   //
  129.   ON_BN_CLICKED(ID_WINDOW_HIDE,FwOnhide)
  130.   //
  131.     ON_BN_CLICKED(ID_OPTIONS_MODIFY,FwOnModifyOpt)
  132.     ON_BN_CLICKED(ID_FILE_PAUSE,FwOnPause)
  133.     ON_BN_CLICKED(ID_LOG_VIEWLOG,FwOniplogLog)
  134.     ON_BN_CLICKED(ID_LOG_VIEWERRORLOG,FwOniplogErr)
  135.     ON_BN_CLICKED(ID_LOG_VIEWTRANSFERS,FwOnViewTransfers)
  136. END_MESSAGE_MAP()
  137.  
  138. /////////////////////////////////////////////////////////////////////////////
  139. // CWinHTTrackApp construction
  140.  
  141. CWinHTTrackApp::CWinHTTrackApp()
  142. {
  143.   // HTTrack inits
  144.   HtsHelper = new LaunchHelp();
  145. }
  146.  
  147. CWinHTTrackApp::~CWinHTTrackApp()
  148. {
  149.   DeleteTabs();
  150.   delete HtsHelper;
  151.   HtsHelper=NULL;
  152. }
  153.  
  154. /////////////////////////////////////////////////////////////////////////////
  155. // The one and only CWinHTTrackApp object
  156.  
  157. CWinHTTrackApp theApp;
  158.  
  159. /////////////////////////////////////////////////////////////////////////////
  160. // CWinHTTrackApp initialization
  161.  
  162. int Eval_Exception( void );
  163.  
  164. int Eval_Exception ( int n_except )
  165. {
  166.     AfxMessageBox("error");
  167.  
  168.     return 0;
  169. }
  170.  
  171. BOOL CWinHTTrackApp::InitInstance()
  172. {
  173.     // Change the registry key under which our settings are stored.
  174.     // TODO: You should modify this string to be something appropriate
  175.     // such as the name of your company or organization.
  176.     SetRegistryKey("WinHTTrack Website Copier");
  177.   LANG_INIT();    // petite init langue
  178.  
  179.   /* INDISPENSABLE pour le drag&drop! */
  180.   if (!AfxOleInit())
  181.   {
  182.     AfxMessageBox(LANG(LANG_F1));
  183.     return FALSE;
  184.   }
  185.     AfxEnableControlContainer();
  186.  
  187.   // Pointeur sur CShellApp
  188.   CShellApp_app=&app;
  189.   this_app=this;
  190.   _Cinprogress_inst=NULL;
  191.   LibRasUse=0;
  192.  
  193.     // Standard initialization
  194.     // If you are not using these features and wish to reduce the size
  195.     //  of your final executable, you should remove from the following
  196.     //  the specific initialization routines you do not need.
  197.  
  198. #ifdef _AFXDLL
  199.     Enable3dControls();            // Call this when using MFC in a shared DLL
  200. #else
  201.     Enable3dControlsStatic();    // Call this when linking to MFC statically
  202. #endif
  203.  
  204.  
  205.   httrack_icon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  206.  
  207.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  208.  
  209.     // Register the application's document templates.  Document templates
  210.     //  serve as the connection between documents, frame windows and views.
  211.  
  212.   // DOC //
  213.     CMultiDocTemplate* pDocTemplate;
  214.     pDocTemplate = new CMultiDocTemplate(
  215.         IDR_MAINFRAME,
  216.         RUNTIME_CLASS(CWinHTTrackDoc),
  217.         RUNTIME_CLASS(CSplitterFrame),       // main SDI frame window
  218.         RUNTIME_CLASS(CView)); 
  219.     AddDocTemplate(pDocTemplate);
  220.  
  221.   /*
  222.     CMDIFrameWnd* pMainFrame = new CMDIFrameWnd;
  223.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  224.         return FALSE;
  225.   */
  226.  
  227.     // create main window
  228.     CMainFrame* pMainFrame = new CMainFrame;
  229.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  230.         return FALSE;
  231.     m_pMainWnd = pMainFrame;
  232.     int nCmdShow = m_nCmdShow;
  233.  
  234.   // enable file manager drag/drop and DDE Execute open
  235.   EnableShellOpen();
  236.   RegisterShellFileTypes();
  237.   // register "New File" handler
  238.   HKEY phkResult;
  239.   DWORD creResult;
  240.   if (RegCreateKeyEx(HKEY_CLASSES_ROOT,".whtt",0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&phkResult,&creResult)==ERROR_SUCCESS) {
  241.     RegCloseKey(phkResult);
  242.     if (RegCreateKeyEx(HKEY_CLASSES_ROOT,".whtt\\ShellNew",0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&phkResult,&creResult)==ERROR_SUCCESS) {
  243.       char voidbuff='\0';
  244.       RegSetValueEx(phkResult,"NullFile",0,REG_SZ,(LPBYTE)&voidbuff,1);
  245.       RegCloseKey(phkResult);
  246.     }
  247.   }
  248.  
  249.  
  250.   // Also in this example, there is only one menubar shared between
  251.     //  all the views.  The automatic menu enabling support of MFC
  252.     //  will disable the menu items that don't apply based on the
  253.     //  currently active view.  The one MenuBar is used for all
  254.     //  document types, including when there are no open documents.
  255.  
  256.   // enable file manager drag/drop and DDE Execute open
  257.     pMainFrame->DragAcceptFiles();
  258.  
  259.   // Now finally show the main menu
  260.     //pMainFrame->ShowWindow(m_nCmdShow);
  261.     //pMainFrame->UpdateWindow();
  262.     m_pMainWnd = pMainFrame;
  263.  
  264.   // command line arguments are ignored, create a new (empty) document
  265.     //OnFileNew();
  266.   // DOC //
  267.  
  268.     // Parse command line for standard shell commands, DDE, file open
  269.     CCommandLineInfo cmdInfo;
  270.     ParseCommandLine(cmdInfo);
  271.  
  272.   hts_rootdir((char*)AfxGetApp()->m_pszHelpFilePath);
  273.  
  274.   // Restore position
  275.     ((CMainFrame*)m_pMainWnd)->InitialShowWindow(nCmdShow);
  276.     pMainFrame->UpdateWindow();
  277.  
  278.     // Dispatch commands specified on the command line
  279.     if (!ProcessShellCommand(cmdInfo))
  280.         return FALSE;
  281.  
  282.   // Init Winsock
  283.   WSockInit();
  284.  
  285.     // The one and only window has been initialized, so show and update it.
  286.     //m_pMainWnd->ShowWindow(SW_SHOW);
  287.     //m_pMainWnd->UpdateWindow();
  288.  
  289.   /*CWinApp* app=AfxGetApp();
  290.   POSITION pos;
  291.   pos=app->GetFirstDocTemplatePosition();
  292.   CDocTemplate* templ = app->GetNextDocTemplate(pos);
  293.   pos=templ->GetFirstDocPosition();
  294.   CDocument* doc  = templ->GetNextDoc(pos);
  295.  
  296.   CRuntimeClass* pRuntimeClass = RUNTIME_CLASS( CTest );
  297.   CObject* pObject = pRuntimeClass->CreateObject();
  298.   ASSERT( pObject->IsKindOf( RUNTIME_CLASS( CTest ) ) );
  299.   
  300.   doc->AddView((CView*) pObject);
  301.   */
  302.  
  303.   {
  304.     // Infos la 1ere fois!
  305.     CWinApp* pApp = AfxGetApp();
  306.     if (pApp->GetProfileInt("Interface","FirstRun",0) != 3) {
  307.       pApp->WriteProfileInt("Interface","FirstRun",3);
  308.       Cabout about;
  309.       about.DoModal();
  310.       
  311.       // Default proxy?
  312.       if (maintab) {
  313.         maintab->DefineDefaultProxy();
  314.         if (maintab->DoModal()!=IDCANCEL) {
  315.           // Default proxy values
  316.           CString strSection       = "OptionsValues";
  317.           MyWriteProfileString("",strSection, "Proxy",maintab->m_option10.m_proxy);
  318.           MyWriteProfileString("",strSection, "Port",maintab->m_option10.m_port);
  319.         }
  320.         maintab->UnDefineDefaultProxy();
  321.       }
  322.     }
  323.   }
  324.   
  325.  
  326. #ifdef HTTRACK_AFF_WARNING
  327. #ifndef _DEBUG
  328.   AfxMessageBox("--WARNING--\r\n"HTTRACK_AFF_WARNING);
  329. #endif
  330. #endif
  331.  
  332.   return TRUE;
  333. }
  334.  
  335.  
  336. BOOL CWinHTTrackApp::WSockInit() {
  337.   // Initialiser WINSOCK
  338.   WORD   wVersionRequested; /* requested version WinSock API */ 
  339.   WSADATA wsadata;        /* Windows Sockets API data */
  340.   {
  341.     int stat;
  342.     wVersionRequested = 0x0101;
  343.     stat = WSAStartup( wVersionRequested, &wsadata );
  344.     if (stat != 0) {
  345.       //HTS_PANIC_PRINTF("Winsock not found!\n");
  346.     } else if (LOBYTE(wsadata.wVersion) != 1  && HIBYTE(wsadata.wVersion) != 1) {
  347.       //HTS_PANIC_PRINTF("WINSOCK.DLL does not support version 1.1\n");
  348.       WSACleanup();
  349.     }
  350.   }
  351.   // Fin Initialiser WINSOCK
  352.   return TRUE;
  353. }
  354.  
  355. /////////////////////////////////////////////////////////////////////////////
  356. // CAboutDlg dialog used for App About
  357.  
  358. /*
  359. class CAboutDlg : public CDialog
  360. {
  361. public:
  362.     CAboutDlg();
  363.  
  364. // Dialog Data
  365.     //{{AFX_DATA(CAboutDlg)
  366.     enum { IDD = IDD_ABOUTBOX };
  367.     //}}AFX_DATA
  368.  
  369.     // ClassWizard generated virtual function overrides
  370.     //{{AFX_VIRTUAL(CAboutDlg)
  371.     protected:
  372.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  373.     //}}AFX_VIRTUAL
  374.  
  375. // Implementation
  376. protected:
  377.     //{{AFX_MSG(CAboutDlg)
  378.         // No message handlers
  379.     //}}AFX_MSG
  380.     DECLARE_MESSAGE_MAP()
  381. };
  382.  
  383. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  384. {
  385.     //{{AFX_DATA_INIT(CAboutDlg)
  386.     //}}AFX_DATA_INIT
  387. }
  388.  
  389. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  390. {
  391.     CDialog::DoDataExchange(pDX);
  392.     //{{AFX_DATA_MAP(CAboutDlg)
  393.     //}}AFX_DATA_MAP
  394. }
  395.  
  396. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  397.     //{{AFX_MSG_MAP(CAboutDlg)
  398.         // No message handlers
  399.     //}}AFX_MSG_MAP
  400. END_MESSAGE_MAP()
  401. */
  402.  
  403. // App command to run the dialog
  404. void CWinHTTrackApp::OnAppAbout()
  405. {
  406.   Cabout about;
  407.   about.DoModal();
  408. //    CAboutDlg aboutDlg;
  409. //    aboutDlg.DoModal();
  410. }
  411.  
  412.  
  413. /* Request: Set new view in the splitter window (when clicking on finished, for example) */
  414. void CWinHTTrackApp::OnViewRestart() {
  415.   //CloseAllDocuments(FALSE);
  416.   //OnFileNew();
  417.   this_CSplitterFrame->SetNewView(0,1,RUNTIME_CLASS(CDialogContainer));
  418. }
  419.  
  420. void CWinHTTrackApp::OnWizRequest1() {
  421.   wizard diawiz;
  422.   diawiz.m_question=WIZ_question;
  423.   diawiz.DoModal();
  424.   strcpy(WIZ_reponse,diawiz.m_reponse);
  425. }
  426.  
  427. void CWinHTTrackApp::OnWizRequest2() {
  428.   wizard2 diawiz2;
  429.   diawiz2.m_question=WIZ_question;
  430.   if (diawiz2.DoModal()==IDOK)
  431.   strcpy(WIZ_reponse,"YES");
  432.   else
  433.     strcpy(WIZ_reponse,"NO");
  434. }
  435.  
  436. void CWinHTTrackApp::OnWizRequest3() {
  437.   WizLinks diawiz3;
  438.   diawiz3.m_url=WIZ_question;
  439.   if (diawiz3.DoModal()==IDskipall)
  440.     strcpy(WIZ_reponse,"*");
  441.   else
  442.     switch(diawiz3.m_lnk) {
  443.     case 0:
  444.       strcpy(WIZ_reponse,"0");
  445.       break;
  446.     case 1:
  447.       strcpy(WIZ_reponse,"1");
  448.       break;
  449.     case 2:
  450.       strcpy(WIZ_reponse,"2");
  451.       break;
  452.     case 3:
  453.       strcpy(WIZ_reponse,"4");
  454.       break;
  455.     case 4:
  456.       strcpy(WIZ_reponse,"5");
  457.       break;
  458.     case 5:
  459.       strcpy(WIZ_reponse,"6");
  460.       break;
  461.     default:
  462.       strcpy(WIZ_reponse,"");
  463.       break;
  464.   }
  465. }
  466.  
  467.  
  468. //
  469.  
  470.  
  471. /////////////////////////////////////////////////////////////////////////////
  472. // CWinHTTrackApp message handlers
  473.  
  474. // Ne fait pas partie de la classe
  475. /*
  476. UINT RunBackEngine( LPVOID pP ) {
  477.   static int running=0;
  478.   if (running)
  479.     return 0;
  480.   running=1;
  481.   {
  482.     CWinApp* app=AfxGetApp();
  483.     POSITION pos;
  484.     pos=app->GetFirstDocTemplatePosition();
  485.     CDocTemplate* templ = app->GetNextDocTemplate(pos);
  486.     pos=templ->GetFirstDocPosition();
  487.     CDocument* doc  = templ->GetNextDoc(pos);
  488.     pos=doc->GetFirstViewPosition();
  489.     CView*     view = doc->GetNextView(pos);
  490.     App_Main_HWND=view->m_hWnd;
  491.   }
  492.   //
  493.   CShellApp app;
  494.   app.InitInstance();
  495.   running=0;
  496.   return 0;
  497. }
  498. */
  499.  
  500. /*
  501. void CWinHTTrackApp::OnWizard() {
  502.   //this_CSplitterFrame->SetNewView(0,1,RUNTIME_CLASS(CDialogContainer));
  503. }
  504. */
  505.  
  506. afx_msg void CWinHTTrackApp::OnFileNew( ) {
  507.   OpenDocumentFile("");
  508. }
  509.  
  510. afx_msg void CWinHTTrackApp::OnFileOpen( ) {
  511.   this->CWinApp::OnFileOpen();
  512. }
  513.  
  514. void CWinHTTrackApp::OnFileSave() {
  515. }
  516.  
  517. void CWinHTTrackApp::OnFileSaveAs() 
  518. {
  519.     // TODO: Add your command handler code here
  520.     
  521. }
  522.  
  523. void CWinHTTrackApp::OnFileDelete()
  524. {
  525.   static char szFilter[256];
  526.   strcpy(szFilter,"WinHTTrack Website Copier Project (*.whtt)|*.whtt||");
  527.   CFileDialog* dial = new CFileDialog(true,"whtt",NULL,OFN_HIDEREADONLY,szFilter);
  528.   if (dial->DoModal() == IDOK) {
  529.     CString st=dial->GetPathName();
  530.     if (fexist((char*) LPCTSTR(st))) {
  531.       int pos=st.ReverseFind('.');
  532.       CString dir=st.Left(pos)+"\\";
  533.       char msg[1000];
  534.       sprintf(msg,"%s\r\n%s",LANG_DELETECONF,dir);
  535.       if (AfxMessageBox(msg,MB_OKCANCEL)==IDOK) {
  536.         if (remove(st)) {
  537.           AfxMessageBox("Error deleting "+st);
  538.         } else {
  539.           RmDir(dir);
  540.         }
  541.       }
  542.     } else
  543.       AfxMessageBox(LANG(LANG_G26 /*"File not found!","Fichier introuvable!"*/));
  544.   }
  545.   delete dial;
  546. }
  547.  
  548. void CWinHTTrackApp::OnBrowseWebsites()
  549. {
  550.   CString st=dialog0->GetBasePath();
  551.  
  552.   if (st.GetLength()<=1) {
  553.     CString strSection       = "DefaultValues";    
  554.     CWinApp* pApp = AfxGetApp();
  555.     st = pApp->GetProfileString(strSection, "BasePath");
  556.     st += "\\";
  557.   }
  558.  
  559.   st+="index.html";
  560.   ShellExecute(NULL,"open",st,"","",SW_RESTORE);    
  561. }
  562.  
  563. BOOL CWinHTTrackApp::RmDir(CString srcpath) {
  564.   CWaitCursor wait;
  565.  
  566.   if (srcpath.GetLength()==0)
  567.     return FALSE;
  568.   CString path=srcpath;
  569.   WIN32_FIND_DATA find;
  570.   if (path.Right(1)!="\\")
  571.     path+="\\";  
  572.   HANDLE h = FindFirstFile(path+"*.*",&find);
  573.   if (h != INVALID_HANDLE_VALUE) {
  574.     do {
  575.       if (!(find.dwFileAttributes  & FILE_ATTRIBUTE_SYSTEM ))
  576.       if (strcmp(find.cFileName,".."))
  577.       if (strcmp(find.cFileName,"."))
  578.         if (!(find.dwFileAttributes  & FILE_ATTRIBUTE_DIRECTORY )) {
  579.           if (remove(path+find.cFileName)) {
  580.             AfxMessageBox("Error deleting "+path+find.cFileName);
  581.             return FALSE;
  582.           }
  583.         } else {
  584.           if (!RmDir(path+find.cFileName))
  585.             return FALSE;
  586.         }
  587.     } while(FindNextFile(h,&find));
  588.     FindClose(h);
  589.   }
  590.   if (rmdir(srcpath)) {
  591.     AfxMessageBox("Error deleting "+srcpath);
  592.     return FALSE;
  593.   }
  594.   return TRUE;
  595. }
  596.  
  597.  
  598. void CWinHTTrackApp::OnFileMruFile1() 
  599. {
  600.     // TODO: Add your command handler code here
  601.     
  602. }
  603.  
  604. void CWinHTTrackApp::Onipabout() 
  605. {
  606.   Cabout about;
  607.   about.DoModal();
  608. }
  609.  
  610. void CWinHTTrackApp::OnUpdate() 
  611. {
  612.   CString st;
  613.   st.Format(HTS_UPDATE_WEBSITE,HTS_PLATFORM,LANGUAGE_NAME);
  614.   HtsHelper->Help(st);
  615. }
  616.  
  617. // Appel aide
  618. BOOL CWinHTTrackApp::OnHelpInfo2() {
  619.   return OnHelpInfo(NULL);
  620. }
  621.  
  622. BOOL CWinHTTrackApp::OnHelpInfo(HELPINFO* dummy) 
  623. {
  624.   HtsHelper->Help("step2.html");
  625.   return true;
  626. }
  627.  
  628. // Forwards
  629.  
  630. void CWinHTTrackApp::FwOnhide() {
  631.   if (this_CSplitterFrame)
  632.     this_CSplitterFrame->Onhide();
  633.   else
  634.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  635. }
  636.  
  637. void CWinHTTrackApp::FwOnLoadprofile() {
  638.   if ((dialog1!=NULL) && (maintab!=NULL))
  639.     dialog1->OnLoadprofile();
  640.   else
  641.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  642. }
  643. void CWinHTTrackApp::FwOnSaveprofile() {
  644.   if ((dialog1!=NULL) && (maintab!=NULL))
  645.     dialog1->OnSaveprofile();
  646.   else
  647.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  648. }
  649. void CWinHTTrackApp::FwOnLoaddefault() {
  650.   if ((dialog1!=NULL) && (maintab!=NULL))
  651.     dialog1->OnLoaddefault();
  652.   else
  653.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  654. }
  655. void CWinHTTrackApp::FwOnSavedefault() {
  656.   if ((dialog1!=NULL) && (maintab!=NULL))
  657.     dialog1->OnSavedefault();
  658.   else
  659.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  660. }
  661. void CWinHTTrackApp::FwOnResetdefault() {
  662.   if ((dialog1!=NULL) && (maintab!=NULL))
  663.     dialog1->OnResetdefault();
  664.   else
  665.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  666. }
  667.  
  668. //
  669.  
  670. void CWinHTTrackApp::FwOnModifyOpt() {
  671.   if ((inprogress!=NULL) && (maintab!=NULL))
  672.     inprogress->OnModifyOpt();
  673.   else
  674.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  675. }
  676.  
  677. void CWinHTTrackApp::FwOnPause() {
  678.   if ((inprogress!=NULL) && (maintab!=NULL))
  679.     inprogress->OnPause();
  680.   else
  681.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  682. }
  683.  
  684. void CWinHTTrackApp::FwOniplogLog() {
  685.   if ((inprogress!=NULL) && (maintab!=NULL))
  686.     inprogress->OniplogLog();
  687.   else
  688.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  689. }
  690.  
  691. void CWinHTTrackApp::FwOniplogErr() {
  692.   if ((inprogress!=NULL) && (maintab!=NULL))
  693.     inprogress->OniplogErr();
  694.   else
  695.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  696. }
  697.  
  698. void CWinHTTrackApp::FwOnViewTransfers() {
  699.   if ((inprogress!=NULL) && (maintab!=NULL))
  700.     inprogress->OnViewTransfers();
  701.   else
  702.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  703. }
  704.  
  705. CDocument* CWinHTTrackApp::OpenDocumentFile( LPCTSTR lpszFileName)
  706. {
  707.   // Eviter deux fenΩtres (un seul document)
  708.   // Le CMultui..->CSingleDoc.. est trop complexe α changer (α cause du splitter-wnd)
  709.   int count=1;
  710.  
  711.   { /* Check if a document exists, and if exists if empty or not, and if name is different */
  712.     POSITION pos;
  713.     pos=GetFirstDocTemplatePosition();
  714.     if (pos) {
  715.       CDocTemplate* tmpl=GetNextDocTemplate(pos);
  716.       if (tmpl) {
  717.         pos=tmpl->GetFirstDocPosition();
  718.         if (pos) {
  719.           CDocument* doc  = tmpl->GetNextDoc(pos);
  720.           if (doc) {
  721.             if (dialog0->GetName().GetLength()==0) {
  722.               CloseAllDocuments(FALSE);
  723.               count=0;        /* No documents */
  724.             } else {
  725.               if (dialog0->GetPath0()+".whtt" == LPCSTR(lpszFileName))
  726.                 return NULL;
  727.             }
  728.           }
  729.         } else
  730.           count=0;          /* No documents */
  731.       }
  732.     }
  733.   }
  734.  
  735.   // Ouvrir nouvelle instance
  736.   if (count) {
  737.     char cmdl[2048];
  738.     CWinApp* pApp = AfxGetApp();
  739.     CString name = pApp->m_pszHelpFilePath;
  740.     name=name.Left(name.GetLength()-4);
  741.     name += ".EXE";
  742.     strcpy(cmdl,"\"");
  743.     strcat(cmdl,lpszFileName);
  744.     strcat(cmdl,"\"");
  745.     ShellExecute(NULL,"open",name,cmdl,"",SW_RESTORE);
  746.     return NULL;
  747.   }
  748.  
  749.   // Ouvrir nouveau?
  750.   //if (count)
  751.   //  return;       // ne rien faire, car limitΘ α 1 document
  752.   //count++;
  753.  
  754.   /* Ouvrir */
  755.   /*
  756.   CWinApp* app=AfxGetApp();
  757.   POSITION pos;
  758.   pos=app->GetFirstDocTemplatePosition();
  759.   CDocTemplate* templ = app->GetNextDocTemplate(pos);
  760.   pos=templ->GetFirstDocPosition();
  761.   if (pos) {
  762.     CDocument* doc  = templ->GetNextDoc(pos);
  763.     if (doc)
  764.       if (!doc->SaveModified())
  765.         return NULL;
  766.   }
  767.   CloseAllDocuments(FALSE);
  768.   */
  769.   if (strlen(lpszFileName))
  770.     return CWinApp::OpenDocumentFile(lpszFileName);
  771.   else
  772.     CWinApp::OnFileNew();
  773.   return NULL;
  774. }
  775.  
  776. void CWinHTTrackApp::NewTabs() {
  777.   DeleteTabs();
  778.   m_tab0 = new CFirstInfo();
  779.   m_tab1 = new CNewProj();
  780.   m_tab2 = new Wid1();
  781.   m_tab3 = new Ctrans();
  782.   m_tabprogress = new Cinprogress();
  783.   m_tabend = new Cinfoend();
  784. }
  785.  
  786. void CWinHTTrackApp::DeleteTabs() {
  787.   if (m_tab0)
  788.   if (m_tab0->GetSafeHwnd())       /* a dΘja ΘtΘ dΘtruit par CWinApp */
  789.     delete m_tab0;
  790.   if (m_tab1)
  791.   if (m_tab1->GetSafeHwnd())
  792.     delete m_tab1;
  793.   if (m_tab2)
  794.   if (m_tab2->GetSafeHwnd())
  795.     delete m_tab2;
  796.   if (m_tab3)
  797.   if (m_tab3->GetSafeHwnd())
  798.     delete m_tab3;
  799.   if (m_tabprogress)
  800.   if (m_tabprogress->GetSafeHwnd())
  801.     delete m_tabprogress;
  802.   if (m_tabend)
  803.   if (m_tabend->GetSafeHwnd())
  804.     delete m_tabend;
  805.  
  806.   m_tab0=NULL;
  807.   m_tab1=NULL;
  808.   m_tab2=NULL;
  809.   m_tab3=NULL;
  810.   m_tabprogress=NULL;
  811.   m_tabend=NULL;
  812. }
  813.  
  814. int CWinHTTrackApp::ExitInstance() 
  815. {
  816.   LANG_DELETE();
  817.     return CWinApp::ExitInstance();
  818. }
  819.